<template>
	<view class="mine-container" :style="{ height: `${windowHeight}px` }">
		<!--顶部个人信息栏-->
		<view class="header-section">
			<view class="flex padding justify-between">
				<view class="flex align-center">
					<view v-if="!avatar" class="cu-avatar xl round bg-white">
						<view class="iconfont icon-people text-gray icon"></view>
					</view>
					<image v-if="avatar" @click="handleToAvatar" :src="avatar" class="cu-avatar xl round" mode="widthFix"></image>
					<view v-if="!name" @click="handleToLogin" class="login-tip">点击登录</view>
					<view v-if="name" @click="handleToInfo" class="user-info">
						<view class="u_title">用户名：{{ name }}</view>
					</view>
				</view>
				<view @click="handleToInfo" class="flex align-center">
					<text>个人信息</text>
					<view class="iconfont icon-right"></view>
				</view>
			</view>
			<view class="vip-card-box">
				<image class="card-bg" src="/static/vip-card-bg.png" mode=""></image>
				<view class="b-btn">查看详细</view>
				<view class="tit">
					<text class="yticon icon-iLinkapp-"></text>
					DClod会员
				</view>
			</view>
		</view>

		<view class="card-container">
			<uni-card class="card2">
				<view class="card-content">
					<image src="../../static/logo.png" class="card-image"></image>
					我的卡包
					<image src="../../static/logo.png" class="card-image1"></image>
				</view>
			</uni-card>
		</view>
		<view class="card-container">
			<uni-card class="card2" @click="content">
				<view class="card-content">
					<image src="../../static/logo.png" class="card-image"></image>
					我的课程
					<image src="../../static/logo.png" class="card-image1"></image>
				</view>
			</uni-card>
		</view>
		<view class="card-container">
			<uni-card class="card2">
				<view class="card-content">
					<image src="../../static/logo.png" class="card-image"></image>
					我的教练
					<image src="../../static/logo.png" class="card-image1"></image>
					<list-cell icon="icon-dizhi" iconColor="#5fcda2" title="我的教练"></list-cell>
				</view>
			</uni-card>
		</view>
	</view>
</template>

<script>
import storage from '@/utils/storage';

export default {
	data() {
		return {
			name: this.$store.state.user.name,
			version: getApp().globalData.config.appInfo.version
		};
	},
	computed: {
		avatar() {
			return this.$store.state.user.avatar;
		},
		windowHeight() {
			return uni.getSystemInfoSync().windowHeight - 0;
		}
	},
	methods: {
		handleToInfo() {
			this.$tab.navigateTo('/pages/mine/info/index');
		},
		handleToEditInfo() {
			this.$tab.navigateTo('/pages/mine/info/edit');
		},
		handleToSetting() {
			this.$tab.navigateTo('/pages/mine/setting/index');
		},
		handleToLogin() {
			this.$tab.reLaunch('/pages/login');
		},
		handleToAvatar() {
			this.$tab.navigateTo('/pages/mine/avatar/index');
		},
		handleLogout() {
			this.$modal.confirm('确定注销并退出系统吗？').then(() => {
				this.$store.dispatch('LogOut').then(() => {
					this.$tab.reLaunch('/pages/index');
				});
			});
		},
		handleHelp() {
			this.$tab.navigateTo('/pages/mine/help/index');
		},
		handleAbout() {
			this.$tab.navigateTo('/pages/mine/about/index');
		},
		handleJiaoLiuQun() {
			this.$modal.showToast('QQ群：①133713780、②146013835');
		},
		handleBuilding() {
			this.$modal.showToast('模块建设中~');
		},
		content() {
			uni.navigateTo({
				url: `/pages/mine/courses`
			});
		}
	}
};
</script>

<style lang="scss">
page {
	background-color: #f5f6f7;
}
.vip-card-box {
	display: flex;
	flex-direction: column;
	color: #f7d680;
	height: 100upx;
	background: linear-gradient(left, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.8));
	border-radius: 16upx 16upx 0 0;
	overflow: hidden;
	position: relative;
	padding: 20upx 24upx;
	.card-bg {
		position: absolute;
		top: 20upx;
		right: 0;
		width: 380upx;
		height: 260upx;
	}
	.b-btn {
		position: absolute;
		right: 20upx;
		top: 16upx;
		width: 132upx;
		height: 40upx;
		text-align: center;
		line-height: 40upx;
		font-size: 22upx;
		color: #ffffff;
		border-radius: 20px;
		background: linear-gradient(left, #f9e6af, #ffd465);
		z-index: 1;
	}
	.tit {
		font-size: 2upx;
		color: #f7d680;
		margin-bottom: 28upx;
		.yticon {
			color: #f6e5a3;
			margin-right: 16upx;
		}
	}
	.e-b {
		font-size: 3upx;
		color: #d8cba9;
		margin-top: 10upx;
	}
}
.Vip {
	color: #ffaa00;
}
.card2 {
	height: 56px;
	background-color: #4a4a4a;
	display: flex;
	border: none;
	align-items: center; /* 垂直居中 */
	height: 100%; /* 高度100%，使内容垂直居中 */
}
.card3 {
	width: 20px;
	height: 20px;
	background-color: #000000;
}

.card-image {
	width: 20px; /* 调整图片大小 */
	height: 20px;
	margin-right: 8px; /* 图片和文本之间的间距 */
	align-items: center; /* 垂直居中 */
}
.card-image1 {
	width: 20px; /* 调整图片大小 */
	height: 20px;
	margin-left: 220px; /* 图片和文本之间的间距 */
	align-items: center; /* 垂直居中 */
}
.card-content {
	color: white;
	display: flex;
	align-items: center;
}
.card-container {
	margin: 10px;
	background-color: #000000;
	height: 56px;
}
.mine-container {
	width: 100%;
	height: 60vh;
	background-color: #000000;
	.header-section {
		padding: 15px 15px 15px 15px;
		background-color: #000000;
		color: white;

		.login-tip {
			font-size: 18px;
			margin-left: 10px;
		}

		.cu-avatar {
			border: 2px solid #adadad;

			.icon {
				font-size: 40px;
			}
		}

		.user-info {
			margin-left: 15px;

			.u_title {
				font-size: 18px;
				line-height: 30px;
			}
		}
	}

	.content-section {
		position: relative;
		top: 80px;

		.mine-actions {
			margin: 15px 15px;
			padding: 20px 0px;
			border-radius: 8px;
			background-color: white;

			.action-item {
				.icon {
					font-size: 28px;
				}

				.text {
					display: block;
					font-size: 13px;
					margin: 8px 0px;
				}
			}
		}
	}
}
</style>
